package org.boticelli.controller;

import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.boticelli.util.ColorHelper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * Serves a CSS file defining all log colors. It basically renders
 * a ".col<i>" rule where <i> is an index to the color table defined 
 * in {@link ColorHelper}
 * 
 * @author shelmberger
 */
@Controller
public class ColorController
{
    protected static Logger log = Logger.getLogger(ColorController.class);

    /**
     * Shows the log of a given day.
     * 
     * @param response
     * @param botId
     *          Id of the bot as defined in the bot context. Can be
     *          <code>null</code> if there is only one bot defined.
     * @param day
     *          day of month if <code>null</code> the current day is used.
     * @param month
     *          month if <code>null</code> the current day is used.
     * @param year
     *          year if <code>null</code> the current day is used.
     * @return
     */
    @RequestMapping("/colors")
    public ModelAndView showLog(HttpServletResponse response)
    {
        ModelAndView mav=new ModelAndView("colors_css");
        mav.addObject("colors",ColorHelper.getColors());
        return mav;
    }
}
